/**
 * Description: RegisterInfoServiceImpl.java
 * Copyright (c) 2008-2009  Neo. 
 * All Rights Reserved.
 * @version 1.0  Mar 30, 2009 10:05:09 PM 李萌（neolimeng@gmail.com）created
 */
package org.paradise.dms.services.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.paradise.dms.dao.impl.RegisterInfoDAOImpl;
import org.paradise.dms.pojo.RegisterInfo;
import org.paradise.dms.services.RegisterInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

/**
 * Description: Copyright (c) 2008-2009 Neo. All Rights Reserved.
 * 
 * @version 1.0 Mar 30, 2009 10:05:09 PM 李萌（neolimeng@gmail.com）created
 */
@Service
public class RegisterInfoServiceImpl implements RegisterInfoService {
	private static Logger log = Logger.getLogger(RegisterInfoServiceImpl.class);
	@Autowired
	@Qualifier("registerInfoDAOImpl")
	private RegisterInfoDAOImpl registerInfoDAOImpl;
	List<RegisterInfo> lri;
	RegisterInfo ri;

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.paradise.dms.services.RegisterInfoService#deleteRegisterInfo(int)
	 */
	public boolean deleteRegisterInfo(int registerinfoid) {
		try {
			this.registerInfoDAOImpl.deleteRegisterInfo(registerinfoid);
			log.info("DMS_info_删除一条物品登记信息成功！ 被删除的物品登记信息ID值为：" + registerinfoid);
			return true;
		} catch (Exception e) {
			log.error("DMS_error_Service-删除一条物品登记记录时出错！！登记记录ID值为："
					+ registerinfoid);
			e.printStackTrace();
			return false;
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.paradise.dms.services.RegisterInfoService#getAllRegisterInfo()
	 */
	public List<RegisterInfo> getAllRegisterInfo() {
		try {
			lri = this.registerInfoDAOImpl.getAllRegisterInfo();
			log.info("DMS_info_取得所有物品登记信息成功！");
			return lri;
		} catch (Exception e) {
			log.error("DMS_error_Service-取得所有物品登记时出错!!");
			e.printStackTrace();
			return null;
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.paradise.dms.services.RegisterInfoService#getRegisterInfo(int)
	 */
	public RegisterInfo getRegisterInfo(int registerinfoid) {
		try {
			ri = this.registerInfoDAOImpl.getRegisterInfo(registerinfoid);
			log.info("DMS_info_根据物品外借登记ID取得登记时出错！！登记ID值为：" + registerinfoid);
			return ri;
		} catch (Exception e) {
			log.error("DMS_error_Service-根据物品外借登记ID取得物品登记记录时出错!!物品外借登记ID为："
					+ registerinfoid);
			e.printStackTrace();
			return null;
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.paradise.dms.services.RegisterInfoService#insertRegisterInfo(org.paradise.dms.pojo.RegisterInfo)
	 */
	public boolean insertRegisterInfo(RegisterInfo registerinfo) {
		try {
			this.registerInfoDAOImpl.insertRegisterInfo(registerinfo);
			log.info("DMS_info_插入一条物品外借登记成功！！借者："
					+ registerinfo.getRegistuserstudentno() + " 操作者："
					+ registerinfo.getRegisterinforecordedby());
			return true;
		} catch (Exception e) {
			log.error("DMS_error_Service-插入物品登记记录时出错!!");
			e.printStackTrace();
			return false;
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.paradise.dms.services.RegisterInfoService#updateRegisterInfo(org.paradise.dms.pojo.RegisterInfo)
	 */
	public boolean updateRegisterInfo(RegisterInfo registerinfo) {
		try {
			this.registerInfoDAOImpl.updateRegisterInfo(registerinfo);
			log.info("DMS_info_更新一条物品外借登记成功！！借者："
					+ registerinfo.getRegistuserstudentno() + " 操作者："
					+ registerinfo.getRegisterinforecordedby());
			return true;
		} catch (Exception e) {
			log.error("DMS_error_Service-更新物品登记记录时出错!!");
			e.printStackTrace();
			return false;
		}
	}

	public int getRows() {
		return this.registerInfoDAOImpl.getRows();
	}

	public List<RegisterInfo> listAllRegisterInfo(int pageSize, int startRow) {
		try {
			lri = this.registerInfoDAOImpl.listAllRegisterInfo(pageSize,
					startRow);
			log.info("DMS_info_分页取得所有物品外借登记，成功！！本次读取" + pageSize + "条，起始条为第"
					+ startRow + "条");
			return lri;
		} catch (Exception e) {
			log.error("DMS_error_分页读取所有物品外借登记，失败！！");
			e.printStackTrace();
			return null;
		}
	}

	/**
	 * @return the registerInfoDAOImpl
	 */
	public RegisterInfoDAOImpl getRegisterInfoDAOImpl() {
		return registerInfoDAOImpl;
	}

	/**
	 * @param registerInfoDAOImpl
	 *            the registerInfoDAOImpl to set
	 */
	public void setRegisterInfoDAOImpl(RegisterInfoDAOImpl registerInfoDAOImpl) {
		this.registerInfoDAOImpl = registerInfoDAOImpl;
	}

	public boolean setReturnTime(int registerinfoid) {
		try {
			this.registerInfoDAOImpl.setReturn(registerinfoid);
			log.info("DMS_info_设置物品归还，成功!!归还物品ID值为：" + registerinfoid);
			return true;
		} catch (Exception e) {
			log.error("DMS_error_设置物品归还，失败!!归还物品ID值为：" + registerinfoid);
			e.printStackTrace();
			return false;
		}
	}

	public List<RegisterInfo> getLri() {
		return lri;
	}

	public void setLri(List<RegisterInfo> lri) {
		this.lri = lri;
	}

	public RegisterInfo getRi() {
		return ri;
	}

	public void setRi(RegisterInfo ri) {
		this.ri = ri;
	}

}
